package cn.wbnyua.msm.web.dao;

import cn.wbnyua.msm.web.domain.Goods;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 作者：wbnyua.
 * 创建时间: 2023/2/8 22:56.
 */


@Mapper
public interface GoodsMapper {
    @Select("select * from goods")
    List<Goods> findAll();

    @Select("select * from goods where id = #{id}")
    Goods findById(Long id);

    @Insert("INSERT INTO `msm`.`goods` (`name`, `product_id`, `size`, `retail_price`, `purchase_price`, `stock`, `supplier_id`)" +
            " VALUES (#{name}, #{productId}, #{size}, #{retailPrice}, #{purchasePrice}, #{stock}, #{supplierId})")
    int add(Goods goods);

    @Update("UPDATE `msm`.`goods` SET `name` = '#{name}'," +
            " `product_id` = '#{productId}', `size` = '#{size}'," +
            " `retail_price` = '#{retailPrice}', `purchase_price` = '#{purchasePrice}'," +
            " `stock` = '#{stock}'," +
            " `supplier_id` = '#{supplierId}' WHERE `id` = #{id}")
    int update(Goods goods);

    @Delete("delete from goods where id = #{id}")
    int remove(Long id);
}
